(function (root, site) {
	if(root.Site === undefined) {
		root.Site = site();
	} else {
		console.error("Site has been defined:", window.Site);
	}
})(window, function () {
	return function (str) {
		"use strict";

		var _default = {
			"protocol": "http",
//			 "hostname": "192.168.3.21",
//			"hostname": "183.238.200.171",
//			"hostname":"192.168.3.11",
			"hostname":"192.168.3.8",
			"port": "80",
			"path": ""
		};

		/**
		 * 定义不同服务之间的接口
		 * [注意] path的属性名在配置文件中保持唯一
		 */
		var map = [
			{
				//通知公告参数设置
				"protocol": "http",
				 "port": "8080",
				"path":{
					"getAnnounceType":"/announcementType/getAnnounceType",
					"user.login": "/sysUser/login",
					"findAnnouncement":"/announcement/findAnnouncementByState",
					"findAnnouncementByState":"/groupPoint/findAnnouncementByState",
					"insertAnnouncementType":"/announcementType/insertAnnouncementType",//插入公告类型
					"deleteAnnouncementByUser":"/announcement/deleteAnnouncementByUser",//删除公告
					"addAnnouncement":"/announcement/addAnnouncement",//新增公告
					"viewAnnouncement":"/announcement/viewAnnouncement",//查看公告
					"uploadAttachment":"/relationAnnouncementAttachment/uploadAttachment",//上传附件
					"downAttachment":"/relationAnnouncementAttachment/downAttachment",//下载附件
					"totalUnreadOnUser":"/announcement/totalUnreadOnUser",//未读总数
					"viewRecord":"/relationUserAnnouncement/viewRecord", //公告查看与未查看记录
					"viewDraft":"/announcement/viewDraft",//查看草稿
					"releaseDraft":"/announcement/releaseDraft",//发送或保存草稿
					"getAllNodePlat":"/groupPoint/getAllNodePlat",//树结构
					"deleteAttachment":"/relationAnnouncementAttachment/deleteAttachment"
				}
			},
			{
				"protocol": "ws",
				// "port": "8090",//原先
				"port":"8123",
				"path": {
					//配电监控
					"powerMonitoring": "/electricityWebsocket",
				}
			},
			{
				//环境品质监控
				"protocol": "ws",
				"port": "8100",
				"path": {
					"environmentMonitoring": "/websocket"
				}
			},
			{
				//参数设置
				"protocol": "http",
				// "hostname": "192.168.3.20",  //刘永
				// "port": "8080",
				"port": "8123",
				"path": {
					"u.setting": "/Parameter/updateEcoIndicator",
					"s.setting": "/Parameter/getEcoIndicator",
					"p.setting": "/Parameter/getSpareValue",//查询建筑信息
					"d.setting": "/Parameter/updateSpareValue",//设置、更新节能目标
					"q.electric.singlePhase": "/Parameter/getElectric/single",
					"u.electric.singlePhase": "/Parameter/updateElectric/single",
					"q.electric.threePhase": "/Parameter/getElectric/three",
					"u.electric.threePhase": "/Parameter/updateElectric/three"
				}
			},
			{
//				 "port": "8102",
				"port":"8123",
				"path": {
					//建筑
					"a.building": "/groupPoint/add",
					"d.building": "/groupPoint/delete",
					"m.building": "/groupPoint/modify",
					"s.building": "/groupPoint/groupPointInfo",
					"l.building.all.tree": "/groupPoint/pointList", //查询所有节点的树结构
					"l.building.types": "/groupPoint/listClassification",
					"l.building.listOfBuilding": "/groupPoint/buildingInfo", //分页|不分页查询所有建筑类型的节点
					"l.building.devices": "/groupPoint/duid",
					"f.building.nodes": "/groupPoint/search",
					//设备
					"a.device": "/device/addDevice",
					"b.device":"/deviceRelation/listDeviceByGroupId",
					"q.device":"/device/device",
					"d.device":"/device/delete",
					"m.device": "/device/updateDevice",
					"bindDuids": "/deviceRelation/bindDuids",
					"listUnbind": "/device/listUnbind",
					"unbind": "/deviceRelation/unbind",
					"device.classification": "/device/classification",
					"device.itemizedCode": "/device/itemized",
					"device.batchAdd": "/device/batchAdd",
					//统计
					"statistic.node.day": "/day/day",
					"statistic.node.week": "/day/week",
					"statistic.node.month": "/month/month",
					"statistic.node.quarter": "/month/quarter",
					"statistic.node.year": "/year/year",
					"statistic.childNodes.day": "/day/day/son",
					"statistic.childNodes.week": "/day/week/son",
					"statistic.childNodes.month": "/month/month/son",
					"statistic.childNodes.quarter": "/year/year/son",
					"statistic.childNodes.year": "/month/quarter/son",
					"statistic.grandsonNodes.day": "/day/day/grandson",
					"statistic.grandsonNodes.week": "/day/week/grandson",
					"statistic.grandsonNodes.month": "/month/month/grandson",
					"statistic.grandsonNodes.quarter": "/month/quarter/grandson",
					"statistic.grandsonNodes.year": "/year/year/grandson",
					"statistic.device.day": "/device/day",
					"statistic.device.week": "/device/week",
					"statistic.device.month": "/device/month",
					"statistic.device.quarter": "/device/quarter",
					"statistic.device.year": "/device/year",
					"statistic.allDevices.day": "/device/day/proportion",
					"statistic.allDevices.week": "/device/week/proportion",
					"statistic.allDevices.month": "/device/month/proportion",
					"statistic.allDevices.quarter": "/device/quarter/proportion",
					"statistic.allDevices.year": "/device/year/proportion",
					"statistic.allEnergyBilling": "/billing/getBilling",//能源计费
					"statistic.allBuildings.day": "/day/day/proportion",
					"statistic.allBuildings.week": "/day/week/proportion",
					"statistic.allBuildings.month": "/month/month/proportion",
					"statistic.allBuildings.quarter": "/month/quarter/proportion",
					"statistic.allBuildings.year": "/year/year/proportion",
					"statistic.consumption.childNode.day": "/day/day/itemized",
					"statistic.consumption.childNode.week": "/day/week/itemized",
					"statistic.consumption.childNode.month": "/month/month/itemized",
					"statistic.consumption.childNode.quarter": "/month/quarter/itemized",
					"statistic.consumption.childNode.year": "/year/year/itemized",
					"statistic.informationThrough": "/survey/info",
					"n.building.isFinish":"/diagnose/analyze",//查询建筑是否完成节能目标
					"d.building.effect":"/diagnose/effect", //节能效果-累计节能量
					"statistic.consumption.itemizedForDay":"/day/itemizedForDay", //电分项-日
					"statistic.consumption.itemizedForWeek":"/day/itemizedForWeek", //电分项-周"
					"statistic.consumption.itemizedForMonth":"/month/itemizedForMonth", //电分项-月"
					"statistic.consumption.itemizedForQuarter":"/month/itemizedForQuarter", //电分项-季"
					"statistic.consumption.itemizedForYear":"/year/itemizedForYear", //电分项-年"
					"eachImportantBuildingCoal.day": "/day/importanceBuildingByDay",
					"eachImportantBuildingCoal.week": "/day/importanceBuildingByWeek",
					"eachImportantBuildingCoal.month": "/month/importanceBuildingByMonth",
					"eachImportantBuildingCoal.quarter": "/month/importanceBuildingByQuarter",
					"eachImportantBuildingCoal.year": "/year/importanceBuildingByYear",
					//分析
					"analysis.trend.day": "/trend/day",
					"analysis.trend.month": "/trend/month",
					"analysis.trend.year": "/trend/year",
					"analyze.getRate": "/analyze/getRate",
					"analyze.getContrast": "/analyze/getContrast",
					"analyze.standard": "/analyze/getBenchmarking",
					"analyze.getEnergyFlow": "/analyze/getEnergyFlow",
					//能耗定额
					"quota.get": "/quota/get",
					"quota.set": "/quota/set",
					"quota.update": "/quota/update",
					"quota.getNation": "/quota/getNation",
					"quota.editNation": "/quota/editNation",
					"quota.compare": "/quota/compare",
					//用户
					"user.login": "/user/loginPlatform",  //用户登陆
					"user.add": "/user/add",  //添加用户
					"user.list.all": "/user/allUser",	//查询所有用户
					"user.modify": "/user/updateUser",	//修改用户
					"role.all": "/role/all", //查询所有角色
					"role.add":"/role/addRole",//添加角色
					"role.modify":"/role/editRole",//修改角色
					"role.delete":"/role/deleteRole",//删除角色
					"permission.all":"/url/list",//查询所有url
					"permission.urlRole":"/urlRole/listUrlRole",//查询角色所绑定的url
					"permission.addUrl":"/urlRole/addUrlRole",//添加角色绑定Url
					"permission.batchAddUrl":"/urlRole/batchAddUrlRole",//批量添加角色绑定Url
					"permission.deleteUrl":"/urlRole/deleteUrlRole",//删除角色绑定Url
					"permission.editUrlName":"/url/editName",//编辑url名
					"user.getNotBind": "/user/getNotBind",
					"user.deleteUser": "/user/deleteUser", //删除用户信息
					"user.bindUserBatch": "/user/bindUserBatch",
					"user.bindOpenId": "/user/bindOpenId",// 根据openId 绑定用户 id
					"user.checkPassword":"/user/login",  //校验旧密码
					"user.changePassword":"/user/changePassword", //修改密码
					"user.countRole":"/user/countRole", //统计角色数量
					"user.deleteUserNode":"/user/deleteUserNode",//删除节点关系
					"user.countByRole":"/user/countByRole", //获取角色总数量，在线数，离线数
					"user.adminChangePassword":"/user/resetPassword",//管理员修改用户密码
					//报警
					"alarm.list": "/alarm/list",
					"alarm.process": "/alarm/process",
					//报表报告
					"l.report":"/statement/list",//查询报表
					"d.report":"/statement/download", //下载报表
					"l.presentation":"/report/list",//查询电报告
					"d.presentation":"/report/download",//导出报告
				}
			},
			// {
			// 	"hostname": "192.168.3.20",  //刘永
			// 	"port": "8106",
			// 	path: {
			// 		"alarm.list": "/alarm/list",
			// 		"alarm.process": "/alarm/process",
			// 	}
			// }
		];

		return (function () {
			for(var i = 0; i < map.length; i++) {
				if(map[i].path[str]) {
					var protocol = map[i].protocol || _default.protocol,
						hostname = map[i].hostname || _default.hostname,
						port = map[i].port || _default.port,
						path = map[i].path[str];
					return protocol+"://"+hostname+":"+port+path;
				}
			}
			return "";
		})();
	};
});